home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-197.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  52.1 KB  |  1,470 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 26 Oct 92       Volume 1 : Issue 197
  2.  
  3. Today's Topics:
  4.  
  5.     Can I tell if MacsBug is installed?
  6.     Patching MBDF
  7.     SUIT - anyone try it? (Simple User Interface Toolkit)
  8.     Is a resource fork already open?
  9.  
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. The digest is a collection of article threads from the internet newsgroup
  15. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  16. regularly and want an archive of the discussions.  If you don't know what a
  17. newsgroup is, you probably don't have access to it.  Ask your systems
  18. administrator(s) for details.  (This means you can't post questions to the
  19. digest.)
  20.  
  21. Each issue of the digest contains one or more sets of articles (called
  22. threads), with each set corresponding to a 'discussion' of a particular
  23. subject.  The articles are not edited; all articles included in this digest
  24. are in their original posted form (as received by our news server at
  25. cs.uoregon.edu).  Article threads are not added to the digest until the last
  26. article added to the thread is at least one month old (this is to ensure that
  27. the thread is dead before adding it to the digest).  Article threads that
  28. consist of only one message are generally not included in the digest.
  29.  
  30. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  31. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  32. file /pub/mac/csmp-digest/README before downloading any files.  The most
  33. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  34. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  35. archive has a mail server; send a message with the text '$MACarch help' (no
  36. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  37.  
  38. The digest is also available via email.  Just send a note saying that you
  39. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  40. automatically receive each new issue as it is created.  Sorry, back issues
  41. are not available through the mailing list.
  42.  
  43. Send administrative mail to mkelly@cs.uoregon.edu.
  44.  
  45.  
  46. -------------------------------------------------------
  47.  
  48. From: jon3@quads.uchicago.edu (Jason Jones)
  49. Subject: Can I tell if MacsBug is installed?
  50. Organization: University of Chicago Computing Organizations
  51. Date: Fri, 18 Sep 1992 23:02:47 GMT
  52.  
  53. I'm writing an assert() macro.  When an assertion fails during execution, I'd
  54. like the assertion handler to enter MacsBug, if it is installed (displaying
  55. relevant information via _DebugStr), or display the same information in a
  56. dialog box if MacsBug is not present.
  57.  
  58. So, how do I tell if a low-level debugger is installed?  Comparing the address
  59. of the _Debugger or _DebugStr traps to the address of _Unimplemented didn't
  60. work.  Any suggestions?
  61.  
  62. Also, would anyone be interested in a version of printf that prints to MacsBug
  63. instead of stdout, or a version of sprintf that builds Pascal strings?  Or
  64. did somebody do this a long time ago ...
  65.  
  66. jason.
  67.  
  68. +++++++++++++++++++++++++++
  69.  
  70. From: ksand@apple.com (Kent Sandvik)
  71. Date: 20 Sep 92 18:59:48 GMT
  72. Organization: Apple
  73.  
  74. In article <1992Sep18.230247.14987@midway.uchicago.edu>,
  75. jon3@quads.uchicago.edu (Jason Jones) wrote:
  76. > I'm writing an assert() macro.  When an assertion fails during execution, I'd
  77. > like the assertion handler to enter MacsBug, if it is installed (displaying
  78. > relevant information via _DebugStr), or display the same information in a
  79. > dialog box if MacsBug is not present.
  80.  
  81. > So, how do I tell if a low-level debugger is installed?  Comparing the address
  82. > of the _Debugger or _DebugStr traps to the address of _Unimplemented didn't
  83. > work.  Any suggestions?
  84.  
  85. The information is available in the MacsBug Referenceand Debugging Guide.
  86. When a system error or 68000 exception occurs, the ROM code examines the
  87. global variable MacJmp to obtain the address of the debugger's entry point.
  88.  
  89. If you are running under 24-bit mode, the high-order byte of MacJmp is a 
  90. flags byte that contains the following information:
  91.  
  92. Bit     Meaning
  93. 7       Set if debugger is running
  94. 6       Set if debugger can handle system errors
  95. 5       Set if debugger is installed
  96. 4       Set if debugger can support the Discipline utility
  97.  
  98. The lower 3 bytes of MacJmp (x120) are used to store the address of the
  99. debugger's entry point. 
  100.  
  101. If you are running under a 32-bit Memory Manager, the flags byte is moved
  102. to address $BFF and the long word at MacJmp becomes a full 32-bit address
  103. that points to the debugger's entry point.
  104.  
  105. As for macros, here's something I use a lot in my code:
  106. // MACROS 
  107. // ASSERT Function, used for testing conditions and flagging error states.
  108. #ifdef TESTING
  109. #define        ASSERT(condition,debugMsg)        ((void) 0)
  110. #else
  111. #define        ASSERT(condition,debugMsg)        ((condition) ? (void) 0 :
  112. DebugStr(debugMsg))
  113. #endif
  114.  
  115. > Also, would anyone be interested in a version of printf that prints to MacsBug
  116. > instead of stdout, or a version of sprintf that builds Pascal strings?  Or
  117. > did somebody do this a long time ago ...
  118.  
  119. Mark Lanett posted this recipe some time ago:
  120. void vdebugstr(char* format,...) {
  121.     char buff[257];
  122.     va_list arglist;
  123.     vs_start(arglist,format);
  124.     vsprintf(buff,format,arglist);
  125.     va_end(arglist);
  126.     DebugStr(c2pstr(buff));
  127. }
  128.  
  129. vdebugstr("Hey, index %i is not in range 0..31",index);
  130.  
  131. Kent Sandvik/DTS
  132. "You should really just relax" -MST3K
  133. - -------------------
  134. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  135. DISCLAIMER: Private activities on the Net.
  136.  
  137. +++++++++++++++++++++++++++
  138.  
  139. From: keith@taligent.com (Keith Rollin)
  140. Organization: Taligent
  141. Date: Sun, 20 Sep 1992 23:36:09 GMT
  142.  
  143. In article <ksand-200992115343@wintermute.apple.com>, ksand@apple.com (Kent
  144. Sandvik) wrote:
  145. >In article <1992Sep18.230247.14987@midway.uchicago.edu>,
  146. >jon3@quads.uchicago.edu (Jason Jones) wrote:
  147. >> I'm writing an assert() macro.  When an assertion fails during execution, I'd
  148. >> like the assertion handler to enter MacsBug, if it is installed (displaying
  149. >> relevant information via _DebugStr), or display the same information in a
  150. >> dialog box if MacsBug is not present.
  151. >>
  152. >> So, how do I tell if a low-level debugger is installed?  Comparing the address
  153. >> of the _Debugger or _DebugStr traps to the address of _Unimplemented didn't
  154. >> work.  Any suggestions?
  155. >
  156. >The information is available in the MacsBug Reference and Debugging Guide.
  157. >When a system error or 68000 exception occurs, the ROM code examines the
  158. >global variable MacJmp to obtain the address of the debugger's entry point.
  159. >
  160. >If you are running under 24-bit mode, the high-order byte of MacJmp is a 
  161. >flags byte that contains the following information:
  162. >
  163. >Bit     Meaning
  164. >7       Set if debugger is running
  165. >6       Set if debugger can handle system errors
  166. >5       Set if debugger is installed
  167. >4       Set if debugger can support the Discipline utility
  168. >
  169. >The lower 3 bytes of MacJmp (x120) are used to store the address of the
  170. >debugger's entry point. 
  171. >
  172. >If you are running under a 32-bit Memory Manager, the flags byte is moved
  173. >to address $BFF and the long word at MacJmp becomes a full 32-bit address
  174. >that points to the debugger's entry point.
  175. >
  176.  
  177. Unfortunately, the description in the Macsbug manual on when to check $120
  178. and when to check $BFF sucks the biggie. It's not clear on whether it's
  179. talking about:
  180.  
  181. o Running on a machine with a ROM containing a 32-bit Memory Manager,
  182. o Running on a machine that booted into 32-bit mode, or
  183. o Running on a machine whose CPU is in 32-bit mode because someone called
  184.   SwapMMUMode.
  185.  
  186. I recently looked into Macsbug, and feel that the following is the right
  187. way to determine if the debugger flags are at $120 or $BFF. First, look at
  188. $BFF. If there is an $FF there, then the flags are at $120. If the value at
  189. $BFF is not $FF, then treat them like valid debugger flags.
  190.  
  191. - -----
  192. Keith Rollin
  193. Phantom Programmer
  194. Taligent, Inc.
  195.  
  196. ---------------------------
  197.  
  198. From: bmor@kimbark.uchicago.edu (Brad Morris)
  199. Subject: Patching MBDF
  200. Date: 16 Sep 92 15:27:11 GMT
  201. Organization: University of Chicago Computing Organizations
  202.  
  203. I am trying to write some code to patch the MBDF.  I know about the MBDF handle
  204. in low memory, but how to I stop LoadResource from loading the Apple MBDF
  205. over mine.  I am kind of new at mucking around in this way.  Thanks.
  206.  
  207. Brad Morris
  208. b-morris@uchicago.edu
  209.  
  210. +++++++++++++++++++++++++++
  211.  
  212. From: keith@taligent.com (Keith Rollin)
  213. Date: 17 Sep 92 18:51:56 GMT
  214. Organization: Taligent
  215.  
  216. In article <1992Sep16.152711.4676@midway.uchicago.edu>,
  217. bmor@kimbark.uchicago.edu (Brad Morris) wrote:
  218. > I am trying to write some code to patch the MBDF.  I know about the MBDF handle
  219. > in low memory, but how to I stop LoadResource from loading the Apple MBDF
  220. > over mine.  I am kind of new at mucking around in this way.  Thanks.
  221.  
  222. Won't InitProcMenu work? When the Menu Manager calls LoadResource, I think
  223. it doesn't it with the res ID in the MenuList, which is set by the value
  224. passed to InitProcMenu.
  225.  
  226. - -----
  227. Keith Rollin
  228. Phantom Programmer
  229. Taligent, Inc.
  230.  
  231. +++++++++++++++++++++++++++
  232.  
  233. From: bmor@kimbark.uchicago.edu (Brad Morris)
  234. Date: 18 Sep 92 22:51:07 GMT
  235. Organization: University of Chicago Computing Organizations
  236.  
  237. In article <keith-170992114813@kip-58.taligent.com> keith@taligent.com (Keith Rollin) writes:
  238. >In article <1992Sep16.152711.4676@midway.uchicago.edu>,
  239. >bmor@kimbark.uchicago.edu (Brad Morris) wrote:
  240. >> 
  241. >> I am trying to write some code to patch the MBDF.  I know about the MBDF handle
  242. >> in low memory, but how to I stop LoadResource from loading the Apple MBDF
  243. >> over mine.  I am kind of new at mucking around in this way.  Thanks.
  244. >> 
  245. >
  246. >Won't InitProcMenu work? When the Menu Manager calls LoadResource, I think
  247. >it doesn't it with the res ID in the MenuList, which is set by the value
  248. >passed to InitProcMenu.
  249. >
  250. >-----
  251. >Keith Rollin
  252. >Phantom Programmer
  253. >Taligent, Inc.
  254.  
  255. InitProcMenu says it will go away after the application is done.  I want this
  256. to patch the whole system.  Will InitProcMenu work?
  257.  
  258. Thanks...
  259.  
  260. Brad Morris
  261. b-morris@uchicago.edu
  262.  
  263. +++++++++++++++++++++++++++
  264.  
  265. From: keith@taligent.com (Keith Rollin)
  266. Date: 20 Sep 92 23:25:44 GMT
  267. Organization: Taligent
  268.  
  269. In article <1992Sep18.225107.13048@midway.uchicago.edu>,
  270. bmor@kimbark.uchicago.edu (Brad Morris) wrote:
  271. >In article <keith-170992114813@kip-58.taligent.com> keith@taligent.com (Keith Rollin) writes:
  272. >>In article <1992Sep16.152711.4676@midway.uchicago.edu>,
  273. >>bmor@kimbark.uchicago.edu (Brad Morris) wrote:
  274. >>> 
  275. >>> I am trying to write some code to patch the MBDF.  I know about the MBDF handle
  276. >>> in low memory, but how to I stop LoadResource from loading the Apple MBDF
  277. >>> over mine.  I am kind of new at mucking around in this way.  Thanks.
  278. >>> 
  279. >>
  280. >>Won't InitProcMenu work? When the Menu Manager calls LoadResource, I think
  281. >>it doesn't it with the res ID in the MenuList, which is set by the value
  282. >>passed to InitProcMenu.
  283. >
  284. >InitProcMenu says it will go away after the application is done.  I want this
  285. >to patch the whole system.  Will InitProcMenu work?
  286.  
  287.  
  288. I patch GetResource for globally replacing system resources. Once the
  289. system has a handle to your resource, LoadResource will continue to get
  290. your resource.
  291.  
  292. In the following snippet:
  293.  
  294. o "gMyRefNum" is the resource refNum for my INIT, which holds my MBDF
  295. o My INIT opens itself on the first call to InitAllPacks, and reshuffles
  296. the
  297.   resource chain so that it appears behind the System File.
  298. o MyGetResource saves extra registers because of the comment on page I-113
  299.   of IM.
  300. o "oldGetResource" is a global variable holding the address returned by
  301.   GetToolTrapAddress when I patched GetResource.
  302. o I used THINK C, allowing me the use of A4 globals and inline assembly.
  303.  
  304.  
  305. static pascal Handle    MyGetResource(ResType resType, short resID)
  306. {
  307.     short    oldResFile, newResFile;
  308.     Handle    result;
  309.     
  310.     asm {
  311.         movem.l    a1-a3/d1-d7,-(sp)
  312.     }
  313.  
  314.     SetUpA4();
  315.     
  316.     newResFile = oldResFile = -1;
  317.  
  318.     if (gMyRefNum != 0) {
  319.         //
  320.         // If anyone ever asks for the standard MBDF, give them ours.
  321.         //
  322.         if (resType == 'MBDF' && resID == 0) {
  323.             newResFile = gMyRefNum;
  324.             resID = 1000;
  325.         }
  326.     }
  327.     
  328.     if (newResFile != -1) {
  329.         oldResFile = CurResFile();
  330.         UseResFile(newResFile);
  331.     }
  332.  
  333.     result = oldGetResource(resType, resID);
  334.  
  335.     if (oldResFile != -1)
  336.         UseResFile(oldResFile);
  337.  
  338.     RestoreA4();
  339.  
  340.     asm {
  341.         movem.l (sp)+,a1-a3/d1-d7
  342.     }
  343.     
  344.     return result;
  345. }
  346.  
  347. - -----
  348. Keith Rollin
  349. Phantom Programmer
  350. Taligent, Inc.
  351.  
  352. ---------------------------
  353.  
  354. From: rgonzal@gandalf.rutgers.edu (Ralph Gonzalez)
  355. Subject: SUIT - anyone try it? (Simple User Interface Toolkit)
  356. Date: 17 Sep 92 21:53:54 GMT
  357. Organization: Rutgers Univ., New Brunswick, N.J.
  358.  
  359.  
  360. Has anyone tried the Mac version of SUIT? (Description below.) I tried
  361. the demo and it locked up on me. It sounds terrific, if it really
  362. works!
  363.  
  364. - -Ralph
  365.  
  366. - --------------------------------------------------------------
  367. INTRODUCTION: WHAT IS SUIT?
  368. ===================================
  369. Welcome to SUIT, Simple User Interface Toolkit.
  370.  
  371. SUIT is a library of interface tools developed at the University of
  372. Virginia to help C programmers create sophisticated mouse based
  373. interfaces without the lengthy learning period associated with
  374. traditional user interface toolkits. Ease of learning and fast ramp up
  375. time is central to SUIT's design. The SUIT tutorial is designed to
  376. make the user productive in under two hours.
  377.  
  378. Also central to SUIT design is portability. SUIT programs currently
  379. run without changes to the source code on the following platforms:
  380.     o IBM PC
  381.     o Macintosh
  382.     o Sun3
  383.     o Sun4 (SparcStation)
  384.     o SGI (Silicon Graphics IRIS workstations)
  385.     o DECstation
  386.     o HP 
  387.  
  388. [copied from SUIT readme file, stuff deleted...]
  389. - -- 
  390. Ralph Gonzalez, Computer Science, Rutgers Univ., Camden, NJ
  391. Phone: (609) 757-6122; Internet: rgonzal@elbereth.rutgers.edu
  392. - --
  393.  
  394. +++++++++++++++++++++++++++
  395.  
  396. From: rgonzal@gandalf.rutgers.edu (Ralph Gonzalez)
  397. Date: 17 Sep 92 22:01:45 GMT
  398. Organization: Rutgers Univ., New Brunswick, N.J.
  399.  
  400. Sorry, I forgot to mention a very important fact about SUIT -- it is
  401. free to educational institutions. Below is more info from their
  402. README file, including the long version of their downloading 
  403. instructions!
  404.  
  405. - --------------------------------------------------
  406. WHO CAN GET SUIT?
  407. ==============================
  408. SUIT, including all its source code, is available without charge
  409. to Universities and other non-profit institutions.  For-profit
  410. organizations can send email to 
  411.  
  412.     suit@uvacs.cs.virginia.edu 
  413.  
  414. to find out how they can help support graduate education in America.
  415.  
  416. WHAT DO I NEED AT MY SITE IN ORDER TO USE SUIT? 
  417. ===================================================
  418.     This all depends on the platform you will use:
  419.  
  420.     X WINDOWS: 
  421.         You will need at least X11R4 and gcc 2.1 or later.
  422.         Or any ANSI-compatible C compiler. 
  423.         (If all you have is gcc 1.37.X, send us mail.)
  424.                 
  425.     MAC:
  426.         Think C 5.0 
  427.  
  428.     DOS:
  429.         DOS version 5.0 and Borland C++ version 3.1
  430.     
  431.     WINDOWS:
  432.         Microsoft Windows 3.1 and Borland C++ version 3.1
  433.     
  434.  
  435. HOW TO GET THE SUIT DISTRIBUTION
  436. ========================================
  437. SUIT is available through anonymous ftp from
  438. uvacs.cs.virginia.edu (128.143.8.29). Each SUIT distribution 
  439. package comes with full source code and documentation, though
  440. as explained below, the source and docs are available separately 
  441. as well for those attempting to port SUIT to an architecture we do not
  442. yet support. To set a standard SUIT distribution package for your 
  443. machine: 
  444.  
  445.  
  446. 1.) On your system, make a directory that will hold the 
  447. distribution. For example, in your home directory type:
  448.  
  449.         mkdir suit
  450.  
  451. The process of installing the SUIT distribution causes SUIT to 
  452. create a new directory underneath the one you've created here.
  453.  
  454. 2.) Change your current directory to this new location:
  455.  
  456.         cd suit
  457.  
  458. 3.) Type the following command:
  459.  
  460.         ftp 128.143.8.29
  461.  
  462.  You should see something that looks like:
  463.  
  464.         Connected to 128.143.8.29.
  465.         220 uvacs FTP server (SunOS 4.1) ready.
  466.         Name (128.143.8.29:CookieMonster):
  467.  
  468.     where "CookieMonster" is your login ID.
  469.  
  470.  
  471. 4.) At this prompt, type: 
  472.  
  473.         anonymous
  474.     
  475.     You should see something like this:
  476.     
  477.         331 Guest login ok, send ident as password.
  478.         Password:
  479.  
  480. 5.) Please type in your local login ID as a courtesy. This will not be
  481. echoed back to you, so don't panic.
  482.     You will see:
  483.  
  484.         230 Guest login ok, access restrictions apply.
  485.         ftp>
  486.  
  487. 6.) cd into the SUIT directory by typing:
  488.  
  489.         cd /pub/suit/distribution
  490.  
  491. 7.) cd into the directory named after the hardware platform
  492.     you intend to use:
  493.  
  494.     cd <machine_type>
  495.     where <machine_type> is one of:
  496.  
  497.         sparc         
  498.         sun3
  499.         sgi
  500.         rs6000
  501.     for example:
  502.         cd sparc
  503.             OR 
  504.         cd sun3 
  505.             ETC.
  506.  
  507. 8.) VERY IMPORTANT: set the ftp transfer to use binary mode
  508.     Type:
  509.         binary
  510.  
  511. 9.) transfer the archive
  512.     Type:
  513.         get <machine_type>.tar.Z
  514.  
  515.         for example:    
  516.             get sparc.tar.Z
  517.                 OR
  518.             get sun3.tar.Z
  519.                 ETC.
  520.  
  521.     This file is VERY large. Expect it to take
  522.     several minutes to come over.
  523.     
  524. 10.) leave ftp
  525.     Type:
  526.         quit
  527.  
  528. 11.) uncompress the archive
  529.     Type:
  530.     uncompress < <machine_type>.tar.Z | tar xfh -
  531.     
  532.     for example:
  533.         uncompress < sparc.tar.Z | tar xfh -
  534.  
  535. 12.) CONGRATULATIONS! You've got yourself the SUIT library and header
  536. files! You can now safely remove the <machine_name>.tar file if you so
  537. desire.
  538.  
  539. 13.) Follow the directions in the top level README file to prepare
  540. the SUIT distrbution for your site.
  541.  
  542.  
  543. GETTING SUIT SOURCE
  544. ===========================
  545.     Full source code comes with each distribution package of SUIT
  546.     (same source for all architectures). 
  547.  
  548.     IF YOU ONLY WANT THE SOURCE, you can ftp it from uvacs, as
  549.     described above
  550.  
  551.         ftp uvacs.cs.virginia.edu
  552.         (Be sure to use binary transfer)
  553.         
  554.     in the file called    
  555.  
  556.         /pub/suit/distribution/JustSource/src.tar.Z
  557.  
  558.  
  559.  
  560. GETTING THE SUIT REFERENCE MANUAL
  561. =========================================
  562.     Each standard distribution package of SUIT comes with a
  563.     complete reference manual which describes the SUIT library 
  564.     calls. In the standard distribution, the manual comes in
  565.     the form of a VERY long    postscript file that prints out 
  566.     from last page to first.
  567.     
  568.     If it is more convenient for you to print the manual out from
  569.     first page to last, or if you need just individual reference 
  570.     manual chapters, you can ftp the individual files from uvacs, 
  571.     as explained above. The files are in:
  572.  
  573.         /pub/suit/distribution/JustDocs/RefManBySections.tar.Z
  574.  
  575.     Again, be sure to use binary mode when getting this file.
  576.     (type "binary" at the ftp prompt before typing "get")
  577.  
  578.  
  579. ACKNOWLEDGEMENTS
  580. ========================
  581.  
  582.     Thanks for SUIT are due to its original author, Nathaniel Young, and
  583.     to Roderic Collins, Matt Conway, Jim Defay, Pramod Dwivedi, Robert
  584.     DeLine, Brandon Furlich, Rich Gossweiler, Chris Long, William
  585.     McClennan, Kim Passarella, and Randy Pausch. This work was supported
  586.     in part by the National Science Foundation, the United Cerebral Palsy
  587.     Foundation, the Virginia Engineering Foundation, the Virginia Center
  588.     for Innovative Technology, and SAIC.
  589.     
  590.     TELL US WHAT YOU THINK: 
  591.     We would like to hear from you: if you have 
  592.     any comments about SUIT, please send electronic mail to 
  593.     
  594.         suit@uvacs.cs.Virginia.EDU 
  595.     
  596.     We are very interested in your comments as well as your reports of
  597.     errors, unclear sections, or omissions you find in any part of SUIT.
  598.     
  599.     SUIT (c) 1990, 1991 , 1992
  600.     Copyright Rector and Visitors of the University of Virginia
  601.  
  602.  
  603. - -- 
  604. Ralph Gonzalez, Computer Science, Rutgers Univ., Camden, NJ
  605. Phone: (609) 757-6122; Internet: rgonzal@elbereth.rutgers.edu
  606. - --
  607.  
  608. +++++++++++++++++++++++++++
  609.  
  610. From: jess@gn.ecn.purdue.edu (Jess M Holle)
  611. Organization: Purdue University Engineering Computer Network
  612. Date: Fri, 18 Sep 92 01:52:32 GMT
  613.  
  614. I tried the demo from SUIT briefly.  It was sufficiently slow to convince
  615. me not to spend any more time looking at the package.
  616.  
  617. Jess Holle
  618.  
  619. +++++++++++++++++++++++++++
  620.  
  621. From: gurgle@netcom.com (Pete Gontier)
  622. Date: 18 Sep 92 04:29:12 GMT
  623. Organization: cellular
  624.  
  625. rgonzal@gandalf.rutgers.edu (Ralph Gonzalez) writes:
  626.  
  627. >Has anyone tried the Mac version of SUIT?
  628.  
  629. Yup. Turns out it's not as wonderful as it says it is.
  630. I was under the impression that it defined a relatively high-
  631. level API which used the native API of each platform it
  632. supported, so that buttons would look like Mac buttons on
  633. the Mac, Windows buttons under (gag) Windows, etc.
  634.  
  635. What I saw was somebody defining their own GUI and then
  636. using the native graphics primitives to draw and run it.
  637. Basically, they did all their interface elements with
  638. QuickDraw instead of the Control Manager, etc. And it was
  639. real slow, too.
  640.  
  641. I dunno, perhaps it does serve their purposes well. They're
  642. not trying to provide an ISV toolkit, after all.
  643. - -- 
  644.  Pete Gontier // EC Technology // gurgle@netcom.com
  645.  
  646. +++++++++++++++++++++++++++
  647.  
  648. From: bpb9204@tamsun.tamu.edu (Brent)
  649. Organization: Texas A&M Univ., Inc.
  650. Date: Fri, 18 Sep 1992 05:24:23 GMT
  651.  
  652. jess@gn.ecn.purdue.edu (Jess M Holle) writes:
  653. |I tried the demo from SUIT briefly.  It was sufficiently slow to convince
  654. |me not to spend any more time looking at the package.
  655.  
  656. I have it on my IIsi and it still crawls along.  Especially the constant
  657. redrawing when you hold the mouse button down in a scroll bar.  Geez.
  658.  
  659. It crashed on me several times (the demo, that is) but a few of the 
  660. crashes were because of the underlying graphics they used to draw everything.
  661. Since they relied on the SRGP (Simple Raster Graphics Package, see Foley,
  662. Van Dam, et al) which itself is buggy, SUIT is buggy also.
  663.  
  664. SUIT is a *great* idea -- they are doing for ALL windowing interfaces what
  665. Motif did for X.  I think that, if they get SRGP fixed and sped up, then
  666. SUIT will be a good thing, or at least, usable.  On the up-side, SUIT
  667. is new and changes will be made.  Hopefully soon.
  668.  
  669. - -Brent
  670.  
  671. +++++++++++++++++++++++++++
  672.  
  673. From: boyd@apple.com (Scott Boyd)
  674. Date: 20 Sep 92 00:06:59 GMT
  675. Organization: Apple Computer Inc.
  676.  
  677. In article <1992Sep18.052423.1989@tamsun.tamu.edu>, bpb9204@tamsun.tamu.edu
  678. (Brent) wrote:
  679. > jess@gn.ecn.purdue.edu (Jess M Holle) writes:
  680. > |I tried the demo from SUIT briefly.  It was sufficiently slow to convince
  681. > |me not to spend any more time looking at the package.
  682. > I have it on my IIsi and it still crawls along.  Especially the constant
  683. > redrawing when you hold the mouse button down in a scroll bar.  Geez.
  684. > It crashed on me several times (the demo, that is) but a few of the 
  685. > crashes were because of the underlying graphics they used to draw everything.
  686. > Since they relied on the SRGP (Simple Raster Graphics Package, see Foley,
  687. > Van Dam, et al) which itself is buggy, SUIT is buggy also.
  688. > SUIT is a *great* idea -- they are doing for ALL windowing interfaces what
  689. > Motif did for X.  I think that, if they get SRGP fixed and sped up, then
  690. > SUIT will be a good thing, or at least, usable.  On the up-side, SUIT
  691. > is new and changes will be made.  Hopefully soon.
  692. > -Brent
  693.  
  694. I was pretty disappointed with it.  Slow, clunky, lots of unnecessary
  695. redraw (aka flicker), and so foreign relative to the Macintosh interface
  696. as to be nearly unusable.  I, too, anticipated that it would use the
  697. Mac interface elements where possible, but they nearly completely
  698. abandoned it.  I was very surprised that the *only* menu choice they
  699. provided was to *let* you resize the window!
  700.  
  701. I wish them well, but I hope they choose to avail themselves of
  702. what's there, or that they put some more effort into performance
  703. and usability.  I'm not that concerned that their interface is so
  704. foreign, but it's odd to strike off in a new direction if you're
  705. not offering some considerable advantage in doing so.
  706.  
  707. scott
  708. boyd@apple.com
  709.  
  710. Disclaimer:  personal opinion
  711.  
  712. +++++++++++++++++++++++++++
  713.  
  714. From: tenney@netcom.com (Glenn S. Tenney)
  715. Date: 20 Sep 92 09:11:56 GMT
  716. Organization: Netcom - Online Communication Services (408 241-9760 guest)
  717.  
  718. In article <D88-JWA.92Sep19125057@dront.nada.kth.se> d88-jwa@dront.nada.kth.se (Jon Wdtte) writes:
  719. > ...
  720. >Furthermore, even if SUIT is bug-free (which I doubt) it's still affected
  721. >by SRGPs bugs. THIS IS NOT COMMERCIAL_QUALITY CODE, FOLKS, even though
  722. >the license fee they want for it is $25,000.
  723. > ...
  724.  
  725. I was flabbergasted to get email from the SUIT people saying
  726. that for any non-university to USE their code you'd have to
  727. pay $25,000 site license fee.  They want to fund a grad student
  728. with the money and literally don't want to deal with anyone
  729. who can't afford it.
  730.  
  731. SUIT *might* be interesting, but for $25,000 a company can HIRE
  732. someone to write it from scratch.
  733.  
  734. As an independent, there is no way on earth I can pay $25K.
  735.  
  736. Aside from any performance problems, it looks like something to
  737. avoid.
  738.  
  739. - -- 
  740. Glenn Tenney AA6ER
  741. voice: (415) 574-3420 fax: (415) 574-0546
  742. tenney@netcom.com
  743.  
  744. +++++++++++++++++++++++++++
  745.  
  746. From: amanda@intercon.com (Amanda Walker)
  747. Date: 19 Sep 92 10:49:10 GMT
  748. Organization: InterCon Systems Corporation
  749.  
  750. rgonzal@gandalf.rutgers.edu (Ralph Gonzalez) writes:
  751. > Has anyone tried the Mac version of SUIT? (Description below.) I tried
  752. > the demo and it locked up on me. It sounds terrific, if it really
  753. > works!
  754.  
  755. I got it to work, but on my Quadra 700 it was still much too slow to consider 
  756. using in any kind of commercial quality product.  I was also annoyed that it 
  757. does not conform the Apple User Interface guidelines.  Any multi-platform GUI 
  758. toolkit should provide the same general performance as a native application 
  759. and conform to the platform's look and feel.
  760.  
  761.  
  762. Amanda Walker <amanda@intercon.com>
  763.  
  764. +++++++++++++++++++++++++++
  765.  
  766. From: bpb9204@tamsun.tamu.edu (Brent)
  767. Date: 20 Sep 92 19:32:17 GMT
  768. Organization: Texas A&M Univ., Inc.
  769.  
  770. boyd@apple.com (Scott Boyd) writes:
  771. |In article <1992Sep18.052423.1989@tamsun.tamu.edu>, bpb9204@tamsun.tamu.edu
  772. |(Brent) wrote:
  773. |> 
  774. |> SUIT is a *great* idea -- they are doing for ALL windowing interfaces what
  775. |> Motif did for X.  I think that, if they get SRGP fixed and sped up, then
  776. |> SUIT will be a good thing, or at least, usable.  On the up-side, SUIT
  777. |> is new and changes will be made.  Hopefully soon.
  778. |
  779. |I was pretty disappointed with it.  Slow, clunky, lots of unnecessary
  780. |redraw (aka flicker), and so foreign relative to the Macintosh interface
  781. |as to be nearly unusable.
  782.  
  783. I'll agree: it was extremely slow, it has lots of flicker (like what I
  784. mentioned in my original post - about holding the mouse button down in a
  785. scroll bar), BUT, even though the interface looks different, the controls
  786. such as buttons and scroll bars worked the same.  IMO, it doesn't matter
  787. what the actual interface components look like, but how the user is able
  788. to interact with them.  What I mean is, a scroll bar is a scroll bar if
  789. it has two arrows and a thumb that work as I know.  I don't care if it's
  790. a mac-style 1 pixel wide frame for the scroll bar or a 3D, 3 color job
  791. (ala SUIT or Motif).
  792.  
  793. My point is that even though the interface looked different from the mac's,
  794. it worked the same.  (The popup menu didn't work exactly like a mac's, but
  795. worked just like Motif.)
  796.  
  797. |  I, too, anticipated that it would use the
  798. |Mac interface elements where possible, but they nearly completely
  799. |abandoned it.
  800.  
  801. That's the problem with making a totally portable system:  to avoid
  802. a complex set of platform-specific source code, you need to start from
  803. the fundamentals and build up.  The fundamental here is SRGP, unfortunately.
  804.  
  805. |I wish them well, but I hope they choose to avail themselves of
  806. |what's there, or that they put some more effort into performance
  807. |and usability.  I'm not that concerned that their interface is so
  808. |foreign, but it's odd to strike off in a new direction if you're
  809. |not offering some considerable advantage in doing so.
  810.  
  811. Well, they are offering an advantage, and a practical one at that.  What
  812. they are offering is a decent-looking user interface that can be used
  813. on a variety of platforms with NO CHANGES to a program's source code.
  814. Is this practical for everybody? No.  It is practical for people who, for
  815. example, are in school and must develop programs to run on different 
  816. machines.
  817.  
  818. I'm not totally defending SUIT.  It is far from perfect, it's too slow
  819. and bulky (check out the demo program's size) and it crashes often. 
  820. However, their principle idea is what I'm supporting - you can add a
  821. decent interface to a program easily.
  822.  
  823. - -Brent
  824.  
  825. P.S.  Does anyone know if the TranSkel packages are still available via
  826.  ftp?  This package takes a SUIT-like approach to adding an interface to
  827.  a program AND it uses the standard Mac components.  If anyone knows 
  828.  where I may find it, please reply.
  829. - -- 
  830. - ------------------------------------------------------------------------------
  831. Brent P. Burton, N5VMG                          Department of Computer Science
  832. bpb9204@tamsun.tamu.edu                                   Texas A&M University
  833.        What's a typical family value?  Getting a good buy at WalMart.
  834.  
  835. +++++++++++++++++++++++++++
  836.  
  837. From: ksand@apple.com (Kent Sandvik)
  838. Date: 20 Sep 92 19:12:40 GMT
  839. Organization: Apple
  840.  
  841. In article <nd5nk5p.tenney@netcom.com>, tenney@netcom.com (Glenn S. Tenney)
  842. wrote:
  843. > I was flabbergasted to get email from the SUIT people saying
  844. > that for any non-university to USE their code you'd have to
  845. > pay $25,000 site license fee.  They want to fund a grad student
  846. > with the money and literally don't want to deal with anyone
  847. > who can't afford it.
  848.  
  849. I'm also amazed that we don't for instance write a similar toolkit
  850. as a form of public shareware, take an existing framework that looks 
  851. promising, use the skeleton and write operating system/graphics specific
  852. modules for various other platforms (Mac, Windows, Motif...).
  853.  
  854. If this approach works well with for instance the Gnu tools and compilers,
  855. why not with frameworks as well? This is where I hope universities
  856. would think about publishing code and attributing for public domain
  857. work -- this because we that work in ugly commercial companies are 
  858. always pushed by profit margins and economical realities. Not that
  859. universities have this problem as well.
  860.  
  861. Kent
  862.  
  863. "You should really just relax" -MST3K
  864. - -------------------
  865. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  866. DISCLAIMER: Private activities on the Net.
  867.  
  868. +++++++++++++++++++++++++++
  869.  
  870. From: quinn@cs.uwa.edu.au (Quinn)
  871. Date: 21 Sep 92 02:00:54 GMT
  872. Organization: The University of Western Australia
  873.  
  874. In article <Sep.17.17.53.53.1992.21535@gandalf.rutgers.edu> Ralph
  875. Gonzalez, rgonzal@gandalf.rutgers.edu writes:
  876. >Has anyone tried the Mac version of SUIT? (Description below.) I tried
  877. >the demo and it locked up on me. It sounds terrific, if it really
  878. >works!
  879.  
  880. We got the demo to work but quickly ran screaming from the room.
  881. Sorry but IMHO having to put the pointer inside a text field so
  882. that you can type in it doesn't make a Mac application.
  883.  
  884. Basically it would appear that SUIT attempts to provide OS
  885. transparency at too low a level.  For example it doesn't use the
  886. Mac toolbox to draw or track any of the dialog controls, it does
  887. all the work itself.  While that makes it easier to port (because
  888. you only have to port the drawing primitives) it makes for 
  889. *extremely* un-Mac-like (if you'll pardon the clumsy expression)
  890. applications.
  891.  
  892. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  893. Department of Computer Science, The University of Western Australia
  894.   -- And the scroll bars -- can anyone say ugly!?!
  895.  
  896. ---------------------------
  897.  
  898. From: cinquin@imag.fr ( Philippe Cinquin)
  899. Subject: Is a resource fork already open?
  900. Date: 7 Sep 92 11:48:55 GMT
  901. Organization: IMAG Institute, University of Grenoble, France
  902.  
  903. Sorry if this is a stupid question, but how do you know if the resource fork of
  904. a file is already open?
  905.  
  906. Thanks for your replies. If you email please do so at "ocinquin@timb.imag.fr".
  907.  
  908. +++++++++++++++++++++++++++
  909.  
  910. From: ksand@apple.com (Kent Sandvik)
  911. Date: 7 Sep 92 18:24:33 GMT
  912. Organization: Apple
  913.  
  914. In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) wrote:
  915. > Sorry if this is a stupid question, but how do you know if the resource fork of
  916. > a file is already open?
  917.  
  918. This is Labor day, and I'm the single idiot working here at DTS,
  919. so I couldn't verify if my ramblings are correct or not. Anyway,
  920. OpenRFPerm is the preferred way to open a resource fork for multiple
  921. read-only accesses.
  922.  
  923. Under MultiFinder, OpenRFPerm will not open a specified file twice 
  924. with write access. It will return a -1 and sets ResError to -49
  925. (opWrErr). So I guess that's one way to check out if any other
  926. applications have the resource fork of a special file open for
  927. writing. I assume we are dealing with a multiple updating of resources
  928. (like preferences) synchronization problem.
  929.  
  930. Just my speculation, I'm no Resource Manager guru.
  931. Kent
  932.  
  933.  
  934. "I would rather have a thousands idiots attacking my position, than
  935. have one idiot helping to defend it."    [Paraphrased from Voltaire]
  936. - -------------------
  937. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  938. DISCLAIMER: Private activities on the Net.
  939.  
  940. +++++++++++++++++++++++++++
  941.  
  942. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  943. Date: 8 Sep 92 15:35:20 +1200
  944. Organization: University of Waikato, Hamilton, New Zealand
  945.  
  946. In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  947. > Sorry if this is a stupid question, but how do you know if the resource fork of
  948. > a file is already open?
  949.  
  950. If a file is already open by somebody else, you'll get an error if you try
  951. opening it in a mode that's incompatible with the other person's open mode.
  952.  
  953. But I suspect you're really asking what happens when you open a resource file
  954. twice from the same application. The answer is, you will get the same file
  955. refnum back the second time. So how do you tell that this is happened? It can
  956. be done, without too much low-level messing about.
  957.  
  958. The Resource Manager maintains a chain of currently-open resource files.
  959. It loads the "resource map" structure from each file into memory, and fills
  960. in a link field to chain all the resource maps together. There are two
  961. important low-memory globals that are used for this:
  962.  
  963.     TopMapHndl -- handle to the first resource map in the chain
  964.     CurMap -- refnum of the "current" resource file (returned by
  965.         CurResFile, can be changed with UseResFile to point anywhere
  966.         along the chain).
  967.  
  968. Supposing the state of your resource chain is like this:
  969.  
  970.     TopMapHndl --> map for res file 2 --> map for res file 1
  971.     CurMap -- don't care
  972.  
  973. And you open resource file 3, which wasn't previously open. The resource
  974. chain now becomes this:
  975.  
  976.     TopMapHndl --> map for res file 3 --> map for res file 2 -->
  977.                           map for res file 1
  978.     CurMap -- iorefnum for res file 3
  979.  
  980. If, on the other hand, you try reopening res file 2, you get this
  981. situation:
  982.  
  983.     TopMapHndl --> map for res file 2 --> map for res file 1
  984.     CurMap -- iorefnum for res file 2
  985.  
  986. And if you try reopening res file 1, you get this:
  987.  
  988.     TopMapHndl --> map for res file 2 --> map for res file 1
  989.     CurMap -- iorefnum for res file 1
  990.  
  991. In summary:
  992.  
  993.     * If you open a resource file that wasn't previously open, its
  994.       resource map gets prepended to the top of the chain, and TopMapHndl
  995.       is set to point to it.
  996.     * If you reopen a resource file that was already open, TopMapHndl
  997.       is unchanged.
  998.     * Every time you open a resource file, whether it was previously open
  999.       or not, CurMap is updated to hold the iorefnum of that resource file.
  1000.  
  1001. So here's how to tell, when you open a resource file, whether you really
  1002. opened it or not. First, some useful definitions (this is all in Modula-2,
  1003. by the way):
  1004.  
  1005.     TYPE
  1006.     IORefNum = INTEGER;
  1007.  
  1008.     PROCEDURE GetTopMapHndl() : (*Handle*) ADDRESS;
  1009.      (* returns the current value of TopMapHndl global. *)
  1010.  
  1011.     CODE
  1012.         02EB8H, 00A50H; (* move.l TopMapHndl, (sp) *)
  1013.  
  1014.     PROCEDURE GetTopMap() : IORefNum;
  1015.       (* returns the reference number of the last-opened resource file. *)
  1016.  
  1017.     VAR
  1018.         TempHandle : Handle;
  1019.         TempPtr : POINTER TO IORefNum;
  1020.  
  1021.     BEGIN
  1022.     TempHandle := GetTopMapHndl();
  1023.     TempPtr := TempHandle^ + 20;
  1024.     RETURN
  1025.         TempPtr^
  1026.     END GetTopMap;
  1027.  
  1028. Now here's an example code fragment that opens a resource file:
  1029.  
  1030.       (* get information about current state of resource chain *)
  1031.     PreviousResFile := CurResFile();
  1032.     PreviousTop := GetTopMap();
  1033.  
  1034.       (* open resource file with OpenResFile, OpenRFPerm or whatever, e g *)
  1035.     TheResFile := OpenRFPerm(FileName, VRefNum, Permission);
  1036.  
  1037.     ReallyOpened :=
  1038.         (TheResFile = GetTopMap())
  1039.         AND
  1040.         (TheResFile <> PreviousTop)
  1041.  
  1042. And to close the resource file (but only if it was really opened by you) and
  1043. leave things the way they were before:
  1044.  
  1045.     IF ReallyOpened THEN
  1046.         CloseResFile(TheResFile)
  1047.     END (*IF*);
  1048.     UseResFile(PreviousResFile)
  1049.  
  1050. I have successfully used this code to do things to my running system file.
  1051. And I haven't had a crash yet. crash yet. crash yet.
  1052.  
  1053. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1054. Computer Services Dept                     fax: +64-7-838-4066
  1055. University of Waikato            electric mail: ldo@waikato.ac.nz
  1056. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1057. "Well, perhaps that is because Apple has not yet released any future versions
  1058. of the System software." -- Amanda Walker
  1059.  
  1060. +++++++++++++++++++++++++++
  1061.  
  1062. From: neeri@iis.ethz.ch (Matthias Neeracher)
  1063. Organization: Integrated Systems Laboratory, ETH, Zurich
  1064. Date: Tue, 8 Sep 1992 12:07:09 GMT
  1065.  
  1066. In article <1992Sep8.153520.10687@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  1067. >In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  1068. >> Sorry if this is a stupid question, but how do you know if the resource fork of
  1069. >> a file is already open?
  1070. >
  1071. >If a file is already open by somebody else, you'll get an error if you try
  1072. >opening it in a mode that's incompatible with the other person's open mode.
  1073. >
  1074. >But I suspect you're really asking what happens when you open a resource file
  1075. >twice from the same application. The answer is, you will get the same file
  1076. >refnum back the second time. So how do you tell that this is happened? It can
  1077. >be done, without too much low-level messing about.
  1078.  
  1079. >[Low level messing about deleted :-]
  1080.  
  1081. Excuse me, but am I missing something obvious or is there a much simpler way to
  1082. determine if the resource fork is already open?
  1083.  
  1084. PBGetCatInfo returns a field called ioFlAttrib, and according to
  1085. _Inside Macintosh:Files_, bit 2 of that field is set if the resource
  1086. fork is open.
  1087.  
  1088. Matthias
  1089.  
  1090. - -----
  1091. Matthias Neeracher                                   neeri@iis.ethz.ch
  1092.  "You must have picked up that copy of Scarlett instead of Inside Mac
  1093.   when you tried to find the right call..." -- Keith Rollin
  1094.  
  1095. +++++++++++++++++++++++++++
  1096.  
  1097. From: kent@sunfs3.Camex.COM (Kent Borg)
  1098. Date: 8 Sep 92 20:09:46 GMT
  1099. Organization: Camex Inc., Boston MA
  1100.  
  1101. In article <1992Sep8.153520.10687@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  1102. >In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  1103. >> Sorry if this is a stupid question, but how do you know if the resource fork of
  1104. >> a file is already open?
  1105. >
  1106. >If a file is already open by somebody else, you'll get an error if you try
  1107. >opening it in a mode that's incompatible with the other person's open mode.
  1108. >
  1109. >But I suspect you're really asking what happens when you open a resource file
  1110. >twice from the same application. The answer is, you will get the same file
  1111. >refnum back the second time. So how do you tell that this is happened? It can
  1112. >be done, without too much low-level messing about.
  1113. >
  1114. >The Resource Manager maintains a chain of currently-open resource files.
  1115. >It loads the "resource map" structure from each file into memory, and fills
  1116. >in a link field to chain all the resource maps together. There are two
  1117. >important low-memory globals that are used for this:
  1118. >
  1119. >    TopMapHndl -- handle to the first resource map in the chain
  1120. >    CurMap -- refnum of the "current" resource file (returned by
  1121. >        CurResFile, can be changed with UseResFile to point anywhere
  1122. >        along the chain).
  1123.  
  1124. Um, when the obvious stares me in the face but is missed by the likes
  1125. of Lawrence D'Oliveiro, I tend to assume I am wrong.  However, I just
  1126. did this and if my solution is busted I want to know about it, so it
  1127. is limb climbing time.
  1128.  
  1129. If you want to know whether a file is already open, why not ask by
  1130. calling PBGetFInfo()?  II-115: "If the file is open, the reference
  1131. number of the first access path found is returned in ioFRefNum...".
  1132.  
  1133. On further critical reading, the phrase "first access path found"
  1134. makes me wonder.  Might it be the same as the "first resource file in
  1135. the chain".  No, because PBGetFInfo() doesn't know which interests
  1136. me--or does it?
  1137.  
  1138. Is it what I need?  If a different application has the file open, do I
  1139. get that app's refnum?
  1140.  
  1141. OK, Lawrence, please explain this to me, and now that I have done my
  1142. best to confuse the net.world, explain it to them too.  
  1143.  
  1144. Thanks bunches.
  1145.  
  1146.  
  1147. - --
  1148. Kent Borg            kent@camex.com or (when it is *working*) kentborg@aol.com
  1149.                                             H:(617) 776-6899  W:(617) 426-3577
  1150. As always, things look better when some costs are left out.
  1151.                               -Economist 3-28-92 p. 94
  1152.  
  1153. +++++++++++++++++++++++++++
  1154.  
  1155. From: keith@taligent.com (Keith Rollin)
  1156. Date: 8 Sep 92 21:43:28 GMT
  1157. Organization: Taligent
  1158.  
  1159. In article <NEERI.92Sep8130709@iis.ethz.ch>, neeri@iis.ethz.ch (Matthias
  1160. Neeracher) writes:
  1161. > In article <1992Sep8.153520.10687@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence
  1162. D'Oliveiro, Waikato University) writes:
  1163. > >In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  1164. > >> Sorry if this is a stupid question, but how do you know if the resource
  1165. fork of
  1166. > >> a file is already open?
  1167. > >
  1168. > >If a file is already open by somebody else, you'll get an error if you try
  1169. > >opening it in a mode that's incompatible with the other person's open mode.
  1170. > >
  1171. > >But I suspect you're really asking what happens when you open a resource file
  1172. > >twice from the same application. The answer is, you will get the same file
  1173. > >refnum back the second time. So how do you tell that this is happened? It can
  1174. > >be done, without too much low-level messing about.
  1175. > >[Low level messing about deleted :-]
  1176. > Excuse me, but am I missing something obvious or is there a much simpler way
  1177. to
  1178. > determine if the resource fork is already open?
  1179. > PBGetCatInfo returns a field called ioFlAttrib, and according to
  1180. > _Inside Macintosh:Files_, bit 2 of that field is set if the resource
  1181. > fork is open.
  1182.  
  1183. Sometimes you want to know if the resource fork is open in _your_ application.
  1184. Calling PBGetCatInfo will tell you if the file is open within _any_ application.
  1185. The method Lawrence posted is the proper method.
  1186.  
  1187. (Another method, which is more fun but which is very likely to break at some
  1188. time in the future is to walk the resource chain, pull out refnums, call
  1189. GetFCBInfo on them, and see if the file you are interested in is returned.)
  1190.  
  1191. - --
  1192. Keith Rollin
  1193. Phantom Programmer
  1194. Taligent, Inc.
  1195.  
  1196. +++++++++++++++++++++++++++
  1197.  
  1198. From: ksand@apple.com (Kent Sandvik)
  1199. Date: 8 Sep 92 16:35:34 GMT
  1200. Organization: Apple
  1201.  
  1202. Greg Robbins mentioned to me that the DTS Q&A stack contains the 
  1203. needed information to find out when the resource fork is open
  1204. (silly me, have to add the stack to my On Location database).
  1205.  
  1206. The canonical way is to check if the resource file is open is to
  1207. call PBGetCatInfo and check bit 2 of the ioFilAttrib field. Ugh.
  1208.  
  1209. Kent
  1210. "I would rather have a thousands idiots attacking my position, than
  1211. have one idiot helping to defend it."    [Paraphrased from Voltaire]
  1212. - -------------------
  1213. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  1214. DISCLAIMER: Private activities on the Net.
  1215.  
  1216. +++++++++++++++++++++++++++
  1217.  
  1218. From: zben@ni.umd.edu (Charles B. Cranston)
  1219. Date: 8 Sep 92 23:32:07 GMT
  1220. Organization: UM Home for the Terminally Analytical
  1221.  
  1222. In article <BuA4CH.9C4@taligent.com>, keith@taligent.com (Keith Rollin)
  1223. wrote:
  1224.  
  1225. > Sometimes you want to know if the resource fork is open in _your_
  1226. > application. Calling PBGetCatInfo will tell you if the file is open
  1227. > within _any_ application. The method Lawrence posted is the proper method.
  1228. > (Another method, which is more fun but which is very likely to break at some
  1229. > time in the future is to walk the resource chain, pull out refnums, call
  1230. > GetFCBInfo on them, and see if the file you are interested in is returned.)
  1231.  
  1232. Yeah, I missed the ioFlAttib too, since the doc on the field is so far
  1233. away from the doc on the trap.  I came up with the follwing:
  1234.  
  1235. Do GetCatInfo, if ioFRefNum is zero then no access path onto either fork
  1236. is open, so the resource fork is not open.
  1237.  
  1238. Else use a series of indexed GetFCBInfo calls to look for one that
  1239. matches ParID and NamePtr and has bit 1 set in ioFCBFlags which says
  1240. it is a resource fork path.  I think this is a slightly cleaner version
  1241. of what Keith jokingly suggests...
  1242.  
  1243. zben@ni.umd.edu     -KA3ZDF
  1244.  
  1245. +++++++++++++++++++++++++++
  1246.  
  1247. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1248. Date: 10 Sep 92 03:27:51 GMT
  1249. Organization: University of Waikato, Hamilton, New Zealand
  1250.  
  1251. In article <ksand-080992093511@wintermute.apple.com>, ksand@apple.com (Kent Sandvik) writes:
  1252. > The canonical way is to check if the resource file is open is to
  1253. > call PBGetCatInfo and check bit 2 of the ioFilAttrib field. Ugh.
  1254.  
  1255. Yeah, but that doesn't tell if you if it was opened by the Resource Manager.
  1256. All it tells you is that someone has used OpenRF.
  1257.  
  1258. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1259. Computer Services Dept                     fax: +64-7-838-4066
  1260. University of Waikato            electric mail: ldo@waikato.ac.nz
  1261. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1262.  
  1263. +++++++++++++++++++++++++++
  1264.  
  1265. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1266. Date: 9 Sep 92 15:41:51 +1200
  1267. Organization: University of Waikato, Hamilton, New Zealand
  1268.  
  1269. In article <1992Sep8.153520.10687@waikato.ac.nz>, I posted some code
  1270. showing you how to open a resource file and detect if it was already open.
  1271.  
  1272. That code can actually be simplified a little. Recall that TopMapHndl only
  1273. changes if you open a resource file that wasn't already open. So the
  1274. ReallyOpened condition can be shortened to just "GetTopMap() <> PreviousTop".
  1275.  
  1276. And while we're at it, we don't really need the GetTopMap routine at all.
  1277. Just check the value of TopMapHndl itself. And in Modula-2, you can access
  1278. low-memory globals as based variables.
  1279.  
  1280. Putting this altogether (and noting that PreviousTop is now a Handle, not
  1281. an IORefNum), the new code is:
  1282.  
  1283.     TYPE
  1284.     IORefNum = INTEGER;
  1285.  
  1286.     VAR
  1287.     TopMapHndl [00A50H] : Handle;
  1288.  
  1289. Code to open the file:
  1290.  
  1291.       (* get information about current state of resource chain *)
  1292.     PreviousResFile := CurResFile();
  1293.     PreviousTop := TopMapHndl;
  1294.       (* open resource file with OpenResFile, OpenRFPerm or whatever, e g *)
  1295.     TheResFile := OpenRFPerm(FileName, VRefNum, Permission);
  1296.     ReallyOpened := TopMapHndl <> PreviousTop
  1297.  
  1298. Code to restore things as they were:
  1299.  
  1300.     IF ReallyOpened THEN
  1301.         CloseResFile(TheResFile)
  1302.     END (*IF*);
  1303.     UseResFile(PreviousResFile)
  1304.  
  1305. Sometimes it takes the glare of publicity to get you to think out the *proper*
  1306. way to do something you might have been doing for years...
  1307.  
  1308. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1309. Computer Services Dept                     fax: +64-7-838-4066
  1310. University of Waikato            electric mail: ldo@waikato.ac.nz
  1311. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1312.  
  1313. +++++++++++++++++++++++++++
  1314.  
  1315. From: REEKES@applelink.apple.com (Jim Reekes)
  1316. Date: 11 Sep 92 21:39:07 GMT
  1317. Organization: Apple Computer, Inc.
  1318.  
  1319. In article <1992Sep8.153520.10687@waikato.ac.nz>, ldo@waikato.ac.nz
  1320. (Lawrence D'Oliveiro, Waikato University) wrote:
  1321. > In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  1322. > > Sorry if this is a stupid question, but how do you know if the resource fork of
  1323. > > a file is already open?
  1324. > If a file is already open by somebody else, you'll get an error if you try
  1325. > opening it in a mode that's incompatible with the other person's open mode.
  1326. > But I suspect you're really asking what happens when you open a resource file
  1327. > twice from the same application. The answer is, you will get the same file
  1328. > refnum back the second time. So how do you tell that this is happened? It can
  1329. > be done, without too much low-level messing about.
  1330. > The Resource Manager maintains a chain of currently-open resource files.
  1331. > It loads the "resource map" structure from each file into memory, and fills
  1332. > in a link field to chain all the resource maps together. There are two
  1333. > important low-memory globals that are used for this:
  1334. >     TopMapHndl -- handle to the first resource map in the chain
  1335. >     CurMap -- refnum of the "current" resource file (returned by
  1336. >         CurResFile, can be changed with UseResFile to point anywhere
  1337. >         along the chain).
  1338. >
  1339. > **** some stuff deleted ****
  1340.  
  1341. The best approach to take is to avoid the problem in the first place.
  1342.  
  1343.  
  1344. * Stay away from low memory globals
  1345.  
  1346. * To determine if a file is already open, use PBGetCatInfo.
  1347.  
  1348. * To know when it's safe to close a resource file, make sure you're the
  1349. only one that opened it.  This can be done by first checking the ioFlAttrib
  1350. from PBGetCatInfo *BEFORE* you open the file.  If it's open, then don't
  1351. open is again.  Then you'll know that it's safe to close it.
  1352.  
  1353. * If you call OpenRFPerm with read-only, then you'll always get a new
  1354. FCB and map.  This means it's safe to close it.
  1355.  
  1356. * It's dangerous to have more than one path open to a resource file.
  1357. If one user has a read/write path, and a second use has another read-only
  1358. path, then the first user can change the file and this means the second
  1359. reader is screwed.  The file is corrupted to the 2nd reader's point of
  1360. view.
  1361.  
  1362. * To make things more complicated, and more dangerous, the System file is
  1363. always open and always available to everyone.  You'll always find the
  1364. System
  1365. map in your application's resource chain.  Additionally, any file below
  1366. the System will also be in your chain (fonts, suitcases, input methods,
  1367. etc.)
  1368. These are files you typically never open directly.  Just call GetResource
  1369. and assume it's been opened for you.  This is why system resources have
  1370. unique numbers and types.
  1371.  
  1372. - -----------------------------------------------------------------------
  1373. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  1374.                              |          Sound Manager Expert
  1375. Apple Computer, Inc.         | RAll opinions expressed are mine, and do
  1376. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  1377. Cupertino, CA 95014          |       employer, Apple Computer Inc.S
  1378.  
  1379. +++++++++++++++++++++++++++
  1380.  
  1381. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1382. Date: 19 Sep 92 06:22:54 GMT
  1383. Organization: University of Waikato, Hamilton, New Zealand
  1384.  
  1385. In article <REEKES-110992142814@90.10.20.67>, REEKES@applelink.apple.com (Jim Reekes) writes:
  1386. > In article <1992Sep8.153520.10687@waikato.ac.nz>, ldo@waikato.ac.nz
  1387. > (Lawrence D'Oliveiro, Waikato University) wrote:
  1388.  
  1389. [description of technique for opening a resource file and determining if
  1390. was already open deleted]
  1391.  
  1392. >
  1393. > The best approach to take is to avoid the problem in the first place.
  1394.  
  1395. The problem is writing robust code for fetching resources from files, and
  1396. for putting resources into files.
  1397.  
  1398. >
  1399. > * Stay away from low memory globals
  1400.  
  1401. Unfortunately, this problem cannot be solved without doing this.
  1402.  
  1403. >
  1404. > * To determine if a file is already open, use PBGetCatInfo.
  1405.  
  1406. That just tells you a file is open. It can even tell you a resource fork is
  1407. open. It can't tell you whether the file was actually opened by the Resource
  1408. Manager.
  1409.  
  1410. > * To know when it's safe to close a resource file, make sure you're the
  1411. > only one that opened it.  This can be done by first checking the ioFlAttrib
  1412. > from PBGetCatInfo *BEFORE* you open the file.  If it's open, then don't
  1413. > open is again.  Then you'll know that it's safe to close it.
  1414.  
  1415. Duhhh... race conditions? (Async opens, and all that.)
  1416.  
  1417. > * If you call OpenRFPerm with read-only, then you'll always get a new
  1418. > FCB and map.  This means it's safe to close it.
  1419.  
  1420. That's handy to know.
  1421.  
  1422. > * To make things more complicated, and more dangerous, the System file is
  1423. > always open and always available to everyone.  You'll always find the
  1424. > System
  1425. > map in your application's resource chain.  Additionally, any file below
  1426. > the System will also be in your chain (fonts, suitcases, input methods,
  1427. > etc.)
  1428. > These are files you typically never open directly.  Just call GetResource
  1429. > and assume it's been opened for you.  This is why system resources have
  1430. > unique numbers and types.
  1431.  
  1432. As I said before, the problem is writing robust code for fetching resources
  1433. from files, and for putting resource into files. Ideally, this code should
  1434. work no matter what file it is asked to open. Which means, of course, it
  1435. has to handle the case where the file has already been opened by the Resource
  1436. Manager.
  1437.  
  1438. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1439. Computer Services Dept                     fax: +64-7-838-4066
  1440. University of Waikato            electric mail: ldo@waikato.ac.nz
  1441. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1442. "While cumbersome Corel is busy gobbling up 30 megabytes of your hard drive,
  1443. Windows Draw is getting the job done on a mere 12 megabytes."
  1444.                         -- ad in Aug '92 PC Magazine
  1445.  
  1446. ---------------------------
  1447.  
  1448. End of C.S.M.P. Digest
  1449. **********************
  1450.